package com.tedu.charging.service.user.exception;

import com.tedu.charging.common.pojo.web.ServerResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Throwable.class)
    @ResponseBody
    public ServerResult<String> handleException(Throwable throwable){
        String message = throwable.getMessage();
        throwable.printStackTrace();
        return new ServerResult(500,message,message);
    }
}
